#include "project.h"
// Prototypes:

void amplitudeAdjust(void);
void offsetadjust(void);
void vHighAdjust(void);
void vLowAdjust(void);
void frequencyAdjust(void);
void periodAdjust(void);
void pwmAdjust(void);
void rampSineAdjust(void);

//temporary global for simulation
char lcdStringOut[30];

// Menus:
//make_menu(Name, Next, Previous, Parent, Sibling, SelectFunc, EnterFunc, Text)
//amplitude L1
MAKE_MENU(vAdjust,horizontal,NULL_ENTRY,NULL_ENTRY,amplitude,NULL_FUNC,NULL_FUNC,
"Amplitude adjust");
//->L2
MAKE_MENU(amplitude,offset,NULL_ENTRY,vAdjust,NULL_ENTRY,NULL_FUNC,amplitudeAdjust,"Amplitude");
MAKE_MENU(offset,vPeak,amplitude,vAdjust,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"Offset");
MAKE_MENU(vPeak,vLow,offset,vAdjust,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"vPeak");
MAKE_MENU(vLow,NULL_ENTRY,vPeak,amplitude,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"vLow");

//Time L1
MAKE_MENU(horizontal,NULL_ENTRY,vAdjust,NULL_ENTRY,NULL_ENTRY,NULL_FUNC,NULL_FUNC,
"Frequency Adjust");
//L2
MAKE_MENU(frequency,vAdjust,horizontal,NULL_ENTRY,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"Waveshape,Phase");
MAKE_MENU(period,phase,frequency,horizontal,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"Period");
MAKE_MENU(phase,NULL_ENTRY,period,horizontal,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"phase ");

//L1

MAKE_MENU(waveshape,NULL_ENTRY,horizontal,NULL_ENTRY,pwm,NULL_FUNC,NULL_FUNC,
"WaveShape Parameters");
//L2
MAKE_MENU(pwm,rampSine,NULL_ENTRY,waveshape,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"PWM Duty Cycle");
MAKE_MENU(rampSine,NULL_ENTRY,pwm,waveshape,NULL_ENTRY,NULL_FUNC,NULL_FUNC,"Toggle ramp/sine");

// Functions:
void amplitudeAdjust(void) {
	strcpy(&lcdStringOut[0],"amplitude function was called");
}

void offsetadjust(void) {
	strcpy(&lcdStringOut[0], "offset adjust caller");
}
void vHighAdjust(void) {
	strcpy(&lcdStringOut[0], "vPeak adjust caller");
}
void vLowAdjust(void) {
	strcpy(&lcdStringOut[0], "vLow adjust caller");
}
void frequencyAdjust(void) {
	strcpy(&lcdStringOut[0], "F adjust caller");
}
void periodAdjust(void) {
	strcpy(&lcdStringOut[0], "Period adjust caller");
}
void pwmAdjust(void) {
	strcpy(&lcdStringOut[0], "PWM adjust caller");
}
void rampSineAdjust(void) {
	strcpy(&lcdStringOut[0], "ramp/Sine adjust caller");
}

int main() {
	typedef enum {
		up = 1, down = 2, left = 3, right = 4, action = 5
	} buttonVal;
	uint8_t newButtonVal = 0, oldButtonVal = 6;

	//	LCD_Initialize();
	//	SET_MENU_WRITE_FUNC(LCD_Write_PROGMEM_String);

		SET_MENU(amplitude);

	while (1) {
		if (newButtonVal != oldButtonVal) {
			switch (newButtonVal) {
				case right:
				SET_MENU(SIBLING);
				break;
				case down:
				SET_MENU(NEXT);
				break;
				case left:
				SET_MENU(PARENT);
				break;
				case up:
				SET_MENU(PREVIOUS);
				break;
				case action:
				GO_MENU_FUNC(SELECTFUNC);
				break;
				default:
				break;
			}
			//oldButtonVal = newButtonVal;
			//newButtonVal = 0;
		}
	}
}
